package base.thread.locks;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * 使用 公平重入锁
 * 
 * @author Administrator
 * 
 */
public class ReentrantLockFairBeanchmarkDemo implements Counter {
	private int count = 0;
	private Lock lock;

	public ReentrantLockFairBeanchmarkDemo() {
		lock = new ReentrantLock(true);
	}

	public long getValue() {
		return count;
	}

	public void increment() {
		lock.lock();
		try {
			count++;
		} finally {
			lock.unlock();
		}
	}

}
